home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 285_02 / init.c < prev    next >
Text File  |  1990-07-08  |  1KB  |  54 lines

  1. /*--------------------------------------------------------------------------
  2. **        file:         INIT.C
  3. **        project:    hoc3, "Higher Order Calculator"
  4. */
  5.  
  6. #include <math.h>
  7. #include "hocdecl.h"
  8. #include "hoc3.h"
  9.  
  10.  
  11. static struct  {
  12.          char *name ;
  13.          double cval ;
  14. } consts[] = {
  15.    "PI",    3.14159265358979323846,
  16.    "E",     2.71828182845904523536,
  17.    "GAMMA", 0.57721566490153286060,
  18.    "DEG",   57.29577951308322087680,
  19.    "PHI",   1.61803389974989484820,
  20.    "\0",    0.0
  21. } ;
  22.  
  23. static struct  {
  24.          char     *name ;
  25.          double   (*func)() ;
  26. } builtins[] = {
  27.         "sin",        sin,
  28.         "cos",        cos,
  29.         "atan",        atan,
  30.         "log",        Log,
  31.         "log10",    Log10,
  32.         "exp",        Exp,
  33.         "sqrt",        Sqrt,
  34.         "int",        integer,
  35.         "abs",        fabs,
  36.         "\0",         (void *) 0
  37. } ;
  38.  
  39. void init( void)
  40. {
  41.  int i ;
  42.  Symbol *s ;
  43.  
  44.    for (i=0 ; consts[i].name ; i++)
  45.       (void) install( consts[i].name, VAR, consts[i].cval) ;
  46.    for (i=0 ; builtins[i].name ; i++)
  47.    {
  48.       s = install( builtins[i].name, BLTIN, 0.0) ;
  49.       s->u.ptr = builtins[i].func ;
  50.    }   
  51. }
  52.  
  53. /* end of init.c for HOC3.y */
  54.